// import com.alibaba.druid.DbType;
// import com.alibaba.druid.sql.ast.*;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor*;

// import java.util.ArrayList;
// import java.util.std::list;

#include "SQLDropTableGroupStatement.h"

#include "SQLDDLStatement.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../SQLName.h"
#include "../../../DbType.h"
#include "../../../utils/instanceof.h"

SQLDropTableGroupStatement::SQLDropTableGroupStatement()
{
}

SQLDropTableGroupStatement::SQLDropTableGroupStatement(DbType_ptr   dbType) : SQLStatementImpl(dbType)
{
}

void SQLDropTableGroupStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLDropTableGroupStatement)))
  {
    acceptChild(visitor, name);
  }
  visitor->endVisit(SharedObject(SQLDropTableGroupStatement));
}

SQLObject_list_ptr SQLDropTableGroupStatement::getChildren()
{
  SQLObject_list_ptr  children = std::make_shared<std::list<SQLObject_ptr>>();
  if (name != NULL)
  {
    children->push_back(std::dynamic_pointer_cast<SQLObject>(name));
  }
  return children;
}

SQLName_ptr SQLDropTableGroupStatement::getName()
{
  return name;
}

void SQLDropTableGroupStatement::setName(SQLName_ptr name)
{
  this->name = name;
}

string_ptr  SQLDropTableGroupStatement::getTableGroupName()
{
  if (name == NULL)
  {
    return NULL;
  }

  // if (name instanceof SQLName*) {
  return (name->getSimpleName());
  // }

  // return NULL;
}

BOOL_ptr SQLDropTableGroupStatement::isIfExists()
{
  return ifExists;
}

void SQLDropTableGroupStatement::setIfExists(BOOL_ptr ifNotExists)
{
  this->ifExists = ifNotExists;
}

BOOL_ptr SQLDropTableGroupStatement::replace(SQLExpr_ptr expr, SQLExpr_ptr target)
{
  if (name == expr)
  {
    setName(std::dynamic_pointer_cast<SQLName>(target));
    return BOOL::TRUE;
  }

  return BOOL::FALSE;
}

SQLDDLStatement::DDLObjectType SQLDropTableGroupStatement::getDDLObjectType()
{
  return SQLDDLStatement::DDLObjectType::TABLE_GROUP;
}
